package com.yoki.cloud.common.code.generator.impl;

import com.yoki.cloud.common.code.generator.AbstractCodeGenerator;
import freemarker.template.Configuration;

import java.io.*;
import java.util.*;

/**
 * @author kissy
 * @Description: 代码生成器
 * @date 2017/10/24 下午4:38
 */
public class MgrCodeGenerator extends AbstractCodeGenerator {

    /**
     * 保存文件路径
     */
    private static final String SAVE_PATH_PRE = "C:\\Users\\Sky\\Desktop\\code\\shop\\";
    /**
     * 基础包名
     */
    private static final String BASE_PACKAGE = "com.sunny.joint.cloud";
    /**
     * 模块名，分包用
     */
//    private static final String MODULE_NAME = "raw";

    @Override
    public String getBasePackage() {
        return BASE_PACKAGE;
    }

//    @Override
//    public String getModuleName() {
//        return MODULE_NAME;
//    }

    @Override
    public String getSavePathPre() {
        return SAVE_PATH_PRE;
    }

    @Override
    public String getFtlRelativePath() {
        return "ddd";
    }

    public static void main(String[] args) throws Exception {
        MgrCodeGenerator generator = new MgrCodeGenerator();
        generator.generate();

    }

    @Override
    protected void genFiles(Map beanMap, Configuration cfg) throws IOException {
        genFile(beanMap, cfg,  "Entity.ftl", ".java");
        genFile(beanMap, cfg,  "PageQueryDTO.ftl", "PageQueryDTO.java");
        genFile(beanMap, cfg,  "VO.ftl", "VO.java");
        genFile(beanMap, cfg,  "VOTransform.ftl", "VOTransform.java");
        genFile(beanMap, cfg,  "Assembler.ftl", "Assembler.java");
        genFile(beanMap, cfg,  "CreateCommand.ftl", "CreateCommand.java");
        genFile(beanMap, cfg,  "UpdateCommand.ftl", "UpdateCommand.java");
        genFile(beanMap, cfg,  "PageCommand.ftl", "PageCommand.java");
        genFile(beanMap, cfg,  "Repository.ftl", "Repository.java");
        genFile(beanMap, cfg,  "XmlMapper.ftl", "Mapper.xml");
        genFile(beanMap, cfg,  "Controller.ftl", "Controller.java");
        genFile(beanMap, cfg,  "RestApi.ftl", "RestApi.java");
        genFile(beanMap, cfg,  "Service.ftl", "Service.java");
    }
}
